package com.faymanwang.service.impl;

import com.faymanwang.dao.DbGeneratorDao;
import com.faymanwang.service.DbGeneratorService;
import com.faymanwang.utils.GenUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 代码生成器
 */
@Service("dbGeneratorService")
public class DbGeneratorServiceImpl implements DbGeneratorService {


    @Autowired
    private DbGeneratorDao dbGeneratorDao;

    @Override
    public List<Map<String, String>> queryTableInfo(String tableName) {
        String dbName = GenUtils.getConfig().getString("dbName");
        //表信息
        List<Map<String, String>> tableMsg = dbGeneratorDao.queryTableMsg(dbName, tableName);
        //字段信息
        List<Map<String, String>> columns = dbGeneratorDao.queryColumns(tableName);

        tableMsg.addAll(columns);
        return tableMsg;
    }
}
